﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;

namespace AJWPFAdmin.Core.Components.AJTable.ViewModels
{
    public class AJTableFormSchemaItemTemplateSelector : DataTemplateSelector
    {
        public DataTemplate Input { get; set; }
        public DataTemplate Select { get; set; }
        public DataTemplate MultiSelect { get; set; }
        public DataTemplate DateTimePicker { get; set; }
        public DataTemplate RangePicker { get; set; }
        public DataTemplate CheckBox { get; set; }
        public DataTemplate RadioBox { get; set; }
        public DataTemplate Switch { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is AJTableSearchFormSchema schema)
            {
                switch (schema.Type)
                {
                    case AJTableSchemaType.Input:
                        return Input;
                    case AJTableSchemaType.Select:
                        return Select;
                    case AJTableSchemaType.MultiSelect:
                        return MultiSelect;
                    case AJTableSchemaType.DateTimePicker:
                        return DateTimePicker;
                    case AJTableSchemaType.RangePicker:
                        return RangePicker;
                    case AJTableSchemaType.CheckBox:
                        return CheckBox;
                    case AJTableSchemaType.RadioBox:
                        return RadioBox;
                    case AJTableSchemaType.Switch:
                        return Switch;
                    default:
                        break;
                }
            }
            return null;
        }
    }
}
